//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package view;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class LoginFrame extends JFrame {//目前MainFrame的相关代码还没改
    private JTextField usernameField;
    private JPasswordField passwordField;

    public LoginFrame() {
        this.setTitle("登录界面");
        this.setSize(500, 300);
        this.setDefaultCloseOperation(3);
        this.setLayout(new GridLayout(5, 6));
        JLabel usernameLabel = new JLabel("用户名:");
        this.usernameField = new JTextField();
        JLabel passwordLabel = new JLabel("密码:");
        this.passwordField = new JPasswordField();
        JButton loginButton = new JButton("登录");
        this.add(usernameLabel);
        this.add(this.usernameField);
        this.add(passwordLabel);
        this.add(this.passwordField);
        this.add(new JLabel());
        this.add(loginButton);
        loginButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String username = LoginFrame.this.usernameField.getText();
                String password = new String(LoginFrame.this.passwordField.getPassword());
                if ("1".equals(username) && "1".equals(password)) {
                    LoginFrame.this.dispose();
                    (new MainFrame()).setVisible(true);
                } else {
                    JOptionPane.showMessageDialog(LoginFrame.this, "用户名或密码错误");
                }

            }
        });
    }
}
